package com.game.action;

import com.coment.po.UserPet;
import com.coment.po.roles.Roles;
import com.game.dao.user.roles.RolesDao;
import com.game.dao.user.pet.UserPetDao;
import com.game.logic.roles.RolesService;
import com.xs.action.annotate.ActionController;
import com.xs.action.annotate.ActionMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/// 9-技能
@Slf4j
@ActionController(9)
@RestController
@RequestMapping("/skill")
public class SkillAction {
    private final UserPetDao userPetDao;
    private final RolesService rolesService;

    public SkillAction(RolesDao rolesDao, UserPetDao userPetDao, RolesService rolesService) {
        this.userPetDao = userPetDao;
        this.rolesService = rolesService;
    }

    /// 1.升级角色技能
    @ActionMethod(1)
    @GetMapping("/upgrade")
    public Roles upgrade(String rolesId) {
        return rolesService.tryUpgradeSkill(rolesId);
    }

    /// 2.升级宠物技能
    @ActionMethod(2)
    @GetMapping("/upgradePet")
    public UserPet upgradePet(String userPetId) {
        UserPet byIdMust = userPetDao.findByIdMust(userPetId);
        byIdMust.skillLV++;
        return userPetDao.save(byIdMust);
    }
}
